package com.swak.reactivex.cluster;

import java.util.Map;

import com.swak.Constants;
import com.swak.OS;
import com.swak.utils.Maps;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

@Getter
@Setter
@Accessors(chain = true)
public class ClusterConfig {
	private String name = "Cluster";
	private String peerID;
	private String bindHost = Constants.ANYHOST;
	private Integer heartbeat = Constants.Default_Heartbeat;
	private String hostName = OS.hostName();
	private Integer ioSelectThreads = 1;
	private Integer ioWorkerThreads = 4;
	private Map<String, String> parameters = Maps.newHashMap();

	/**
	 * 开启UDP, 默认使用的是单播
	 */
	private Boolean openUDP = Boolean.TRUE;

	/**
	 * 如果开启 UDP，配置是否开启组播
	 */
	private Boolean openMulticast = Boolean.TRUE;
	private String multicastHost = Constants.Multicast_Host;
	private Integer multicastPort = Constants.Multicast_Port;

	/**
	 * 节点的注册和发现
	 */
	private Discovery discovery = new Discovery();

	@Getter
	@Setter
	@Accessors(chain = true)
	public class Discovery {
		private String mode = Constants.Discovery_Mode;
		private String multicastHost = Constants.Discovery_Multicast_Host;
		private Integer multicastPort = Constants.Multicast_Port;
		private Integer multicastDiscoveryTimes = Constants.Multicast_Discovery_Times;
	}
}
